<?php
#                                                                                 
# author: Cody Sorgenfrey                                       
# (c)2012 South Hill Calvary Chapel                                               
#                                                                                 

include_once("./root.inc.php");
include_once("./mysql/database_info.php");
include_once("./mysql/common.php");
include_once("./common.php");
include_once("libraryactions.php");

$title = "SHCC Office Library";
$meta_key='books, lend, borrow, christian bookstore';
$meta_desc="The vast collection of spiritual wisdom at the South Hill Calvary Chapel Office.";
print_html_head($title ,$meta_key,$meta_desc);
?>
<script type="text/javascript">
	function searchTable(input)
	{
	$(document).ready(function(){
		if (input.value == ""){
			$(".dotted_lines").css("display", "table-row");
			$(".dotted_lines").children().css("opacity", "1");
			document.getElementById("clear").style.visibility = "hidden";
		} else {
			document.getElementById("clear").style.visibility = "visible";
			$(".dotted_lines").css("display", "none");
			$(".dotted_lines").children().css("opacity", ".1");
			var tableRows = document.getElementsByTagName("TR");
			for (var x=1;x<tableRows.length;x++){
				var rowCells = tableRows[x].getElementsByTagName("TD");
				for (var y=0;y<rowCells.length;y++){
					var expr = new RegExp(input.value, "i");
					rowCells[y].style.opacity = ".1";
					try {	
						if (rowCells[y].childNodes.length > 1){
							var offSet = rowCells[y].childNodes[0].innerHTML.search(expr);
						} else {
							var offSet = rowCells[y].innerHTML.search(expr);	
						}
						if (offSet != -1){
							rowCells[y].parentNode.style.display = "table-row";
							rowCells[y].style.opacity = "1";
						}
					} catch(err){
						console.log("cell "+y+" skipped due to error");
					}
				}
			}
		}
	});
	}
	function searchTableFor(str)
	{
		document.getElementById("searchBar").value = str;
		searchTable(document.getElementById("searchBar"));
		$(document).ready(function(){
		$(".dotted_lines").children().css("opacity", "1");
		});
	}
</script>
<?
print_java_head(null);
connect_select_test("SHCCLibrary");
begin_body();
printLoginAndLogoutStuff();
if ($_REQUEST['librarian_cookie'] == 1) printLibrarianPanel();
page_title($title);
if ($_REQUEST['librarian_cookie'] != 1 && $_GET['login'] != 1){	
		printf("<div style=''><p>Welcome to the office library catalog! At the church office we have a few book shelves of books available for anyone in the church to borrow for a month or more to read. To check out a book see Whitney or one of the office staff and we will get you on your way!</p></div><br>");
}
printBookTable();
mysql_close();
end_page_title();
end_body();
?> 